<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="../common/taglib.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>企业登陆</title>
    	
	<link rel="stylesheet" type="text/css" href='<c:url value="/css/login.css"/>'>
	<link rel="stylesheet" type="text/css" href='<c:url value="/css/footer.css"/>'>
    <link href="<c:url value="/css/bootstrap.css"/>" rel="stylesheet" type="text/css" >
    <script src="<c:url value="/js/jquery.min.js"/>" type="text/javascript"></script>
    <script src="<c:url value="/js/jquery.cookie.js"/>" type="text/javascript"></script>
    <script src="<c:url value="/js/security.js"/>" type="text/javascript" ></script>
    <script type="text/javascript">
	    $(function(){
	    	var loginName = $.cookie('hr_loginName');
	    	var password = $.cookie('hr_password');
	    	$('#loginName').val(loginName);
	    	$('#password').val(password);
	    	if(loginName!=undefined && password!=undefined)
	    		document.getElementById("chkbox").checked=true;
	    });
    
	    function cmdEncrypt(form) {
	    	var loginName = form.loginName.value;
	    	var password = form.password.value;
	    	//alert(document.getElementsByName("loginName"));获得是一个数组，不要和document.getElementsById混淆了
	    	//alert($('#chkbox').attr('checked'));undefined
	    	if(document.getElementById("chkbox").checked==true){
	    		$.cookie('hr_loginName',loginName,{expires:7,path:'/'});
	    		$.cookie('hr_password',password,{expires:7,path:'/'});
	    	} else {
	    		 $.removeCookie('loginName');  
	             $.removeCookie('password'); 
	    	}
	    	
	    	RSAUtils.setMaxDigits(200);
	        var key = new RSAUtils.getKeyPair("${pubexponent}", "", "${pubmodules}"); 	        
	        var encrypedPwd = RSAUtils.encryptedString(key,form.password.value);  
	        //alert(encrypedPwd);
	        form.password.value = encrypedPwd;
	        form.submit();
	        return true;
	    }
    </script>
  </head>
  </head>

  <body>	
    <div class="container" >
      <form:form modelAttribute="contentModel" method="post" class="form-signin" onsubmit="return cmdEncrypt(this)">
        <h2 class="form-signin-heading">登陆</h2>
        <input type="text" id="loginName" name="loginName" class="form-control" placeholder="登录名" required autofocus>               
        <input type="password" id="password" name="password" class="form-control" placeholder="密码" required>
        <div class="checkbox">
          <label>
            <input type="checkbox" id="chkbox" value="remember-me"> 记住我
          </label>
          &nbsp;&nbsp;<a href='<c:url value="/hr/register"/>'>企业注册</a>
          &nbsp;&nbsp;<a href="<c:url value="/hr/forget"/>">忘记密码</a>
        </div>
        <div style="color:red">
        &nbsp; <form:errors path="loginName"></form:errors>&nbsp; 
        &nbsp; <form:errors path="password"></form:errors>
        </div>
        <button class="btn btn-lg btn-primary btn-block" type="submit">登陆</button>      
        </form:form>
   </div>
        
   <jsp:include page="../common/footer.jsp"></jsp:include>
  </body>
</html>